﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FOModels.BlogNews;
using DataAccess.BlogNews;
using System.Data;
using System.Net;
namespace Bussiness.BlogNews
{
    public class BlogNewsBLL
    {
        private BlogNewsDAL dal;
        public BlogNewsBLL()
        {
            dal = new BlogNewsDAL();
        }
        public List<BlogNewsModels> getBlogNewByCateNotID(int BlogNewsCategoryID, int langid,int BlogNewsID)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getBlogNewByCateNotID(BlogNewsCategoryID, langid, BlogNewsID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<BlogNewsModels> getBlogNewByCate(int BlogNewsCategoryID, int langid)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getBlogNewByCate(BlogNewsCategoryID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public BlogNewsModels getTOP1BlogNewByCate(int BlogNewsCategoryID, int langid)
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.getTOP1BlogNewByCate(BlogNewsCategoryID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {

                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());

                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public List<BlogNewsModels> getTOp3BlogNewsByIDNotID(int langid, int BlogNewsID)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getTOp3BlogNewsByIDNotID(langid, BlogNewsID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public BlogNewsModels getTOp1BlogNewsByBlogNewsHot(int langid)
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.getTOpBlogNewsByBlogNewsHot(langid, 1);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public BlogNewsModels getTOp1BlogNewsByID(int langid)
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.getTOp1BlogNewsByID(langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public List<BlogNewsModels> getTOpBlogNewsByBlogNewsHotNotBlogNewsID(int BlogNewsID, int langid, int top)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getTOpBlogNewsByBlogNewsHotNotBlogNewsID(BlogNewsID, langid, top);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        /*
        public List<BlogNewsModels> getReferenceBlogNews(int top, int productid, int BlogNewsid, int langid)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getReferenceBlogNews(top, productid,BlogNewsid, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                    list.Add(fur);
                }

            }
            return list;

        }*/
        public BlogNewsModels getBlogNewsByIDToGet(int BlogNewsID, int langid)
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.getBlogNewsByIDToGet(BlogNewsID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public BlogNewsModels getBlogNewsByParentID(int TOP, int ParentID, int langid)
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.getBlogNewsByParentID(TOP, ParentID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public List<BlogNewsModels> getBlogNewsByParentIDNotBlogNewsID(int TOP, int ParentID, int langid, int BlogNewsID)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getBlogNewsByParentIDNotBlogNewsID(TOP, ParentID, langid, BlogNewsID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsCategoryID = int.Parse(row["BlogNewsCategoryID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                    list.Add(fur);
                }

            }

            return list;
        }
        public BlogNewsModels getBlogNewsByID(int BlogNewsID, int langid)
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.getBlogNewsByID(BlogNewsID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    if (row["UpdateDate"].ToString() != "")
                    {
                        fur.UpdateDate = DateTime.Parse(row["UpdateDate"].ToString());
                    }
                    else
                    {
                        fur.UpdateDate = null;
                    }
                    fur.UpdateUser = row["UpdateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        /*
        public BlogNewsModels getTOPBlogNewsByBlogNewsHot(int top,int langid)
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.getTOPBlogNewsByBlogNewsHot(top,langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public BlogNewsModels getTOPBlogNewsByBlogNewsHotAndProCate(int top, int ProductCID, int langid)
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.getTOPBlogNewsByBlogNewsHotAndProCate(top, ProductCID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public List<BlogNewsModels> getBlogNews(int langid)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getBlogNews(langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                    list.Add(fur);
                }
               
            }
            return list;

        }
        public List<BlogNewsModels> getBlogNewsByProCate(int ProductCID,int langid)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getBlogNewsByProCate(ProductCID,langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                    fur.CreateUser = row["CreateUser"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsSumary = WebUtility.HtmlDecode(row["BlogNewsSumary"].ToString());
                    fur.BlogNewsContent = WebUtility.HtmlDecode(row["BlogNewsContent"].ToString());
                    list.Add(fur);
                }

            }
            return list;

        }
        public List<BlogNewsModels> getCoutBlogNewsByCate(int productid)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getBlogNewsByCate(productid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    list.Add(fur);
                }

            }
            return list;

        }*/
        public BlogNewsModels getTOP1()
        {
            BlogNewsModels fur = new BlogNewsModels();
            DataTable tb = dal.gettop1BlogNews();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public List<BlogNewsModels> getall(int langid)
        {
            List<BlogNewsModels> list = new List<BlogNewsModels>();
            BlogNewsModels fur;
            DataTable tb = dal.getall(langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BlogNewsModels();
                    fur.BlogNewsID = int.Parse(row["BlogNewsID"].ToString());
                    fur.BlogNewsImg = row["BlogNewsImg"].ToString();
                    fur.Enable = bool.Parse(row["Enable"].ToString());
                    fur.BlogNewsTitle = row["BlogNewsTitle"].ToString();
                    fur.FlagImage = row["FlagImage"].ToString();
                    fur.ViewCount = int.Parse(row["ViewCount"].ToString());
                    fur.BlogNewsHot = bool.Parse(row["BlogNewsHot"].ToString());
                    fur.BlogNewsCategoryName = row["BlogNewsCategoryName"].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public int UpdateBlogNews(BlogNewsModels models, int langid)
        {
            if (dal.UpdateBlogNews(models) > 0 && dal.UpdateBlogNewsLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateBlogNewsViewCount(int ViewCount, int BlogNewsID)
        {
            if (dal.UpdateBlogNewsViewCount(ViewCount, BlogNewsID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertBlogNews(BlogNewsModels models)
        {
            if (dal.InsertBlogNews(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertBlogNewsLanng(BlogNewsModels models, int langid)
        {
            if (dal.InsertBlogNewsLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteBlogNews(int CarLoanID)
        {
            if (dal.DeleteBlogNews(CarLoanID) > 0 && dal.DeleteBlogNewsLang(CarLoanID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }


    }
}
